/***************************************************************
 * Name:      bonusMain.h
 * Purpose:   Defines Application Frame
 * Author:    William Wang ()
 * Created:   2009-06-23
 * Copyright: William Wang ()
 * License:
 **************************************************************/


#ifndef BONUSMAIN_H
#define BONUSMAIN_H

//(*Headers(bonusFrame)
#include <wx/menu.h>
#include <wx/toolbar.h>
#include <wx/grid.h>
#include <wx/frame.h>
//*)
//add header file for logger
#include <wx/log.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/panel.h>
#include <wx/listbook.h>
#include <wx/tokenzr.h>
#include <wx/splitter.h>
#include <wx/html/htmlwin.h>
#include <wx/hyperlink.h>
#include <wx/clipbrd.h>
#include <wx/splash.h>
#include <wx/timer.h>
#include "wx/webview.h"
#include "db_version.h"
////http://www.freeiconsweb.com/free_icons_08.html icon

void initGridByDB(wxGrid * Grid1, char* SQL);

enum
{

   ID_RULE_DESC=10000,//规则说明窗口
   ID_GRID_ID,//GRID标志
   ID_HIDDEN_LOG,//隐藏日志
   ID_SAVE_HTML,  //保存所有记录到一个HTML文件
   ID_SAVE_FORECAST,//保存预测
   ID_OPEN_ANALYST,//打开预测分析窗口
   ID_FILL_BLANK,//填充间隔数据
   ID_PRINT_GRID,//填充间隔数据
   ID_OPEN_BLUEBALL,//打开篮球窗口
   ID_OPEN_HTMLDLG,
   ID_RUN_TESTCASE, //测试分析case
   ID_LEFT_TEST1,
   ID_LEFT_TEST2,
   ID_LEFT_TEST3,
   ID_LEFT_TEST4,
   ID_HTML_HISTORY,
   ID_WATCH_WINDOW,
   ID_TIME_IDFRAME
};

static const int widths[3]={-1,150,60};
class bonusFrame: public wxFrame
{
    public:
   static wxString _WebSite1;//默认地址一
   static wxString _WebSite2;
   static wxString _Range;
    static wxStatusBar* statusbar;
// WX_DECLARE_HASH_MAP(long,wxIEHtmlWin*, wxIntegerHash, wxIntegerEqual,BROWSERS_POINTER);
//BROWSERS_POINTER hasbrowsers;
  //flag zone
  bool saveForecastLight;//保存记录
  bool findBuddyLight;//发现相似记录
  //over flag
       static wxGrid*   Grid1;
       wxPanel *Panel1;//加入画布
       static wxBitmap moneypig;//one
       static wxBitmap money;//one
       static wxIcon appIcon;//系统图标
       static wxTextCtrl * SQLTextBox;//输入SQL 命令的text
       static wxTextCtrl * AIActionWatchTextBox;//观察各种AI分析过程
       static wxHtmlWindow * sqlhtml;//显示最终SQL的HTML

     static wxTextCtrl * LISPCodeBox;
     static wxTextCtrl * LISPCodeName;
     static wxHtmlWindow *lisphtml;
//for log
    static wxTextCtrl     *logWin;
    static wxLogTextCtrl  *logger;
    static wxLog *m_logOld;
//for clipboard
    static wxString _CLIPBOARD;

         wxTimer* m_timer;
//分析策略入口

        bonusFrame(wxWindow* parent,wxWindowID id = -1);
        virtual ~bonusFrame();
        void OnKeyDown(wxKeyEvent& ev);
        static const long ID_PANEL1;//add
        static const long ID_GRID1;
        //清楚主内容区内容
        bool clearMainPanel();
        wxStatusBar* StatusBar1;
        void processMenuEvent(const wxCommandEvent& event);
        void OnHtmlLinkClicked(wxHtmlLinkEvent &event);//处理超链接点击
        void OnCopytoClipBoard(wxCommandEvent& event);

         wxSplitterWindow* split;
                 wxBookCtrlBase *m_bookCtrl;
        wxImageList *m_imageList;

        void analystExpert(wxCommandEvent& event);
        void configdatabase(wxCommandEvent& event);
        void inputSQL(wxCommandEvent& event);//保存数据库
        void runTestCase(wxCommandEvent& event);
        void experts(wxCommandEvent& event);
        void openBrowser(wxCommandEvent& ev);
        void createGridOfFrame(wxCommandEvent& ev);
        void statusbarClick(wxCommandEvent& ev);
        void OnTimer(wxTimerEvent& event);
        void OnIEDialogQuit(wxCommandEvent& event);
        void OnIEHandler(wxCommandEvent& ev);
        //add by w.w 2012.8.29
        void OnError(wxWebViewEvent& evt);
    private:

        //(*Handlers(bonusFrame)
        void OnQuit(wxCommandEvent& event);
        void OnDialogQuit(wxCloseEvent &event);
        void OnAbout(wxCommandEvent& event);
        void OnGrid1CellLeftClick(wxGridEvent& event);
        void OnGrid1CellEditing(wxGridEvent& event);
        void OnRightUp(wxMouseEvent& event);
        void ShowContextMenu(const wxPoint& pos);

        //*)

        //(*Identifiers(bonusFrame)

        static const long idMenuQuit;
        static const long idMenuAbout;
        static const long toolbarAdd;
        static const long toolbarsavedb;
        static const long toolbarHistoryGrid;
        static const long ID_TOOLBAR1;
        //*)
        //manual add
     static const long toolbarThread;
       static const long ID_STATUSBAR1;


    wxMenuItem* MenuItem2;
    wxMenuItem* MenuItem1;


    wxMenu* Menu1;
    wxMenuBar* MenuBar1;
    wxMenu* Menu2;

    //add menu
    wxMenu* Menutools;
    static const long idMenuConfig;
    wxMenuItem* Menu_Config_Item_DBConfig;
    static const long idMenuAnalyst;
    wxMenuItem* Menu_Config_Item_DBAnalyst;


        //(*Declarations(bonusFrame)
        wxToolBar* ToolBar1;
        wxToolBarToolBase* ToolBarItem3;

        wxToolBarToolBase* ToolBarItem1;
        wxToolBarToolBase* ToolBarItem2;

        //*)
        //manual add toolbar itme
          wxToolBarToolBase* ToolBarItem4;
          wxToolBarToolBase* ToolBarItemLeft1;
          wxToolBarToolBase* ToolBarItemLeft2;
          wxToolBarToolBase* ToolBarItemLeft3;
          wxToolBarToolBase* ToolBarItemLeft4;

        DECLARE_EVENT_TABLE();
};

// A small helper class which intercepts all menu events and logs them
class PopMenuEvtHandler : public wxEvtHandler
{
public:
    PopMenuEvtHandler(bonusFrame *frame)
     { m_frame = frame; }

    void OnMenuEvent(wxCommandEvent& event)
    {
        m_frame->processMenuEvent(event);
        event.Skip();
    }

private:
    bonusFrame *m_frame;
    DECLARE_EVENT_TABLE()
};
extern  bonusFrame* BFrame;
extern bool  __DEBUG;
extern  int GRID_ROW;//
extern  int GRID_COL;//
void createHistoryGrid(bonusFrame* frame);
void refreshStastatistics(wxKeyEvent& ev);

#endif // BONUSMAIN_H
/*
    wxFile mmFile;
    void* fileBuffer;
    wxString outpath = wxEmptyString;

    wxFileDialog* OpenFile = new wxFileDialog(this,wxT("Open"),wxEmptyString,wxT("somefile.bin"),wxT("*.bin"),wxOPEN);

    if(OpenFile->ShowModal()==true)
    {
        mmFile.Open(OpenFile->GetPath(),wxFile::read);
        mmFile.Read(fileBuffer,0x1000);
    }

    //tests writing data read from the file.
    outpath=OpenFile->GetDirectory()+wxT("/mania.bin");

        wxFile mmFileNew;
        mmFileNew.Create(outpath,true,wxS_DEFAULT);
        mmFileNew.Write(fileBuffer,0x1000);
*/
